import { defineStore } from 'pinia'
import {
  getHomeBannerList,
  getHomeNavList,
  getHomeNewsList,
  getHomeCakeList,
  getHomeFineProductsList,
  getHomeCommodityList,
} from '@/services/actions'
import { NewsData } from '@/constants/constantType'

export const useHomeStore = defineStore('home', {
  state: () => ({
    newsList: [] as NewsData[],
  }),

  actions: {
    async getBanner() {
      return await getHomeBannerList()
    },
    async getNav() {
      return await getHomeNavList()
    },
    async getNews() {
      const data = await getHomeNewsList()
      this.newsList = data
      return data
    },
    async getCake() {
      return await getHomeCakeList()
    },
    async getFineProducts() {
      return await getHomeFineProductsList()
    },
    async getCommodity() {
      return await getHomeCommodityList()
    },
  },
})
